// components/roomTabs/roomTabs.js
const cloud = require('../../utils/cloudFunction')
const app = getApp()


Component({
    /**
     * Component properties
     */
    properties: {
        homeList: {
            type: Object,
            value: {}
        },
    },

    /**
     * Component initial data
     */
    data: {
        // dispalyStatus:true,

        blank: "|",
        swiperIndex: 0,
        tabTextColor: "grey",
    },

    /**
     * 组件的内部生命周期，详见 开发文档 - 组件生命周期
     * https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/lifetimes.html
     */
    lifetimes: {
        // 渲染组件需要做的的动作
        attached() {

        },

    },
    pageLifetimes: {
        hide() {

        },
        show() {

        }
    },

    /**
     * Component methods
     */
    methods: {

        /**
         * 总控 对应页面跳转
         */
        swiperHome() {
            this.setData({
                swiperIndex: 0
            })
        },
        /**
         * 滑动条 与页面渲染对应
         */
        scrollViewChange(e) {
            // console.log(e.currentTarget.id)
            // 截取id的index，转数字格式
            var id = Number(e.currentTarget.id.substring(4,))
            app.globalData.roomIndex = id
            // console.log("id:" + app.globalData.roomIndex)
            // console.log("sw before:" + this.data.swiperIndex)
            this.setData({
                swiperIndex: id + 1
                // swiperIndex: Number(e.currentTarget.id) + 1
            })
            // console.log("af:" + this.data.swiperIndex)
        },
        /**
         *  左右滑动效果
         */
        swiperChange(e) {
            let indexValue = e.detail.current
            app.globalData.roomIndex = indexValue - 1
            // console.log("id:" + app.globalData.roomIndex)
            this.setData({
                swiperIndex: indexValue
            })

        },

    },


})